class Solution(object):
    def minFlips(self, target):
        state = 0
        ans = 0
        for i in range(1, len(target)):
            if target[i] != target[i - 1]:
                if state == 0 and target[i] == '1':
                    state = 1
                else:
                    state = 1
                    ans += 1
        if state == 0 and target[0] == '0':
            return 0
        return ans + 1
